
@call "L:\Products\LX_Library\settings.cmd"
set lxlib_VersionHigh=%ProductVersionHigh%
set lxlib_VersionMinor=%ProductVersionMinor%
set lxlib_VersionInternal=%ProductVersionInternal%
set lxlib_VersionBuild=%ProductVersionBuild%

@call "%~dp0..\..\settings.cmd"

rem command line parameters:
rem   <1 compiler type>
rem   <2 compiler version>
rem   <3 release type>

rem prepare environment variables
set dbxext_COMPILER_TYPE=%1
if %dbxext_COMPILER_TYPE% == Delphi (set dbxext_COMPILER_CHAR=d) else (set dbxext_COMPILER_CHAR=c)
set dbxext_COMPILER_VER=%2
set dbxext_RELEASE_TYPE=%3
if %dbxext_RELEASE_TYPE% == Trial (set dbxext_COMPILER_DEFINES=__TRIAL__) else (set dbxext_COMPILER_DEFINES=)

set lxlib_COMPILER_VER=%dbxext_COMPILER_VER%
set lxlib_RELEASE_TYPE=%dbxext_RELEASE_TYPE%
set lxlib_COMPILER_TYPE=%dbxext_COMPILER_TYPE%

set dbxext_COMPILER_STR=%dbxext_COMPILER_CHAR%%dbxext_COMPILER_VER%
if %dbxext_COMPILER_STR% == d9 (set dbxext_COMPILER_STR=d2005)
if %dbxext_COMPILER_STR% == d10 (set dbxext_COMPILER_STR=d2006)
set dbxext_ARCHIVE_FILENAME=dbxext_%ProductVersionHigh%.%ProductVersionMinor%.%ProductVersionInternal%.%ProductVersionBuild%%ProductVersionSuffix%_%dbxext_COMPILER_STR%
if %dbxext_RELEASE_TYPE% == Trial (set dbxext_ARCHIVE_FILENAME=%dbxext_ARCHIVE_FILENAME%_trial)
if %dbxext_RELEASE_TYPE% == Sources (set dbxext_ARCHIVE_FILENAME=%dbxext_ARCHIVE_FILENAME%_src)
set dbxext_SETUP_FILENAME=%dbxext_ARCHIVE_FILENAME%_setup

echo.
echo.
echo Make Win32 %dbxext_COMPILER_TYPE% %dbxext_COMPILER_VER% %dbxext_RELEASE_TYPE%
echo -----------------------------
echo.

echo   Cleanup product folder...
call "%BUILDDIR%\cleanup.cmd"

echo   Build product version...
call "%BUILDDIR%\build_%dbxext_COMPILER_CHAR%%dbxext_COMPILER_VER%.cmd" "%dbxext_COMPILER_DEFINES%"
if errorlevel 1 goto exit

echo   Make installation...
%INNOSETUP% "%~dp0.\dbxext.iss" > "%~dp0..\.make.log"
if errorlevel 1 goto error

echo   Archive installation...
if exist %dbxext_ARCHIVE_FILENAME% del /q %dbxext_ARCHIVE_FILENAME% > "%~dp0..\.make.log"
if errorlevel 1 goto exit
set dbxext_SETUP_FILENAME=%dbxext_SETUP_FILENAME%.exe
echo TempMode=Do you wish to continue installation of Luxena dbExpress eXtension?, Luxena dbExpress eXtension setup > "%~dp0.\script.txt"
echo Silent=1 >> "%~dp0.\script.txt"
echo Overwrite=1 >> "%~dp0.\script.txt"
echo Setup=%dbxext_SETUP_FILENAME% >> "%~dp0.\script.txt"
if %dbxext_RELEASE_TYPE% == Release (set dbxext_PASSWORD=-p%passWIN32%) else (if %dbxext_RELEASE_TYPE% == Sources (set dbxext_PASSWORD=-p%passWIN32SOURCE%) else (set dbxext_PASSWORD=))
%WINRAR% a -m5 -md4096 -ep -s -sfx -z"%~dp0.\script.txt" %dbxext_PASSWORD% "%INSTALLDIR%\bin\%dbxext_ARCHIVE_FILENAME%" "%INSTALLDIR%\bin\%dbxext_SETUP_FILENAME%" > "%~dp0..\.make.log"
del /q "%~dp0.\script.txt" > nul
del /q "%INSTALLDIR%\bin\%dbxext_SETUP_FILENAME%" > nul
if errorlevel 1 goto error

:done
del /q "%~dp0..\.make.log"
echo.
echo -----------------------------
echo Make done.
goto exit

:error
type "%~dp0..\.make.log"
pause

:exit
cd %~dp0..\